/** @type {import('next').NextConfig} */
const nextConfig = {
  // API代理配置，将前端API请求转发到后端
  async rewrites() {
    // 从环境变量读取后端地址，默认为localhost:8000
    const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8000';
    
    return [
      {
        source: '/api/:path*',
        destination: `${apiBaseUrl}/api/:path*`,
      },
      {
        source: '/health',
        destination: `${apiBaseUrl}/health`,
      },
    ]
  },
}

module.exports = nextConfig
